import java.util.TimerTask;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-03-23
 * Time: 16:08
 */
//定时器

import java.util.Timer;


public class ThreadDemo5 {

        public static void main(String[] args) {
            Timer timer = new Timer();
            timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    System.out.println("hello4");
                }
            }, 4000);
            timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    System.out.println("hello3");
                }
            }, 3000);
            timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    System.out.println("hello2");
                }
            }, 2000);
            timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    System.out.println("hello1");
                }
            }, 1000);
            System.out.println("hello0");
        }
    }

